package log

import (
	"io/ioutil"
	"parking-lot-go-admin/controller"
	"strings"

	"github.com/gin-gonic/gin"
)

func Show(c *gin.Context) {
	requestData := struct {
		LogDate string `json:"log_date"`
	}{}

	c.ShouldBindJSON(&requestData)
	content, _ := ioutil.ReadFile(requestData.LogDate)
	logShow := string(content)
	logShowNew := strings.Replace(logShow, "\n", "<br>", -1)

	controller.Success(c, map[string]interface{}{
		"log_show": logShowNew,
	})
}
